Imports obout_ASPTreeView_Pro_NET
Imports ccapps.persistent.authorization
'Imports ccapps.persistent.laLocationDefine
Imports ccapps.persistent.common
Imports ccapps.persistent.smeTariffUpdate

Namespace Web.page

    Public Class SmeTariffUpdate_Rapor
        Inherits [lib].BasePage

#Region " Web Form Designer Generated Code "

        'This call is required by the Web Form Designer.
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

        End Sub
        Protected WithEvents TreeView As System.Web.UI.WebControls.Literal
        Protected WithEvents chk_a0 As System.Web.UI.WebControls.CheckBox
        Protected WithEvents ltlAlert As System.Web.UI.WebControls.Literal
        Protected WithEvents Repeater1 As System.Web.UI.WebControls.Repeater
        Protected WithEvents proc As System.Web.UI.HtmlControls.HtmlInputHidden
        Protected WithEvents userid As System.Web.UI.WebControls.TextBox
        Protected WithEvents username As System.Web.UI.WebControls.TextBox
        Protected WithEvents Txt1 As System.Web.UI.HtmlControls.HtmlInputHidden
        Protected WithEvents RadioButton1 As System.Web.UI.WebControls.RadioButton
        Protected WithEvents Radiobutton2 As System.Web.UI.WebControls.RadioButton
        Protected WithEvents Radiobutton3 As System.Web.UI.WebControls.RadioButton
        Protected WithEvents Radiobutton4 As System.Web.UI.WebControls.RadioButton
        Protected WithEvents radio1 As System.Web.UI.WebControls.RadioButtonList
        Protected WithEvents Grid_Rapor1 As System.Web.UI.WebControls.DataGrid
        Protected WithEvents Grid_Rapor2 As System.Web.UI.WebControls.DataGrid
        Protected WithEvents Grid_Rapor3 As System.Web.UI.WebControls.DataGrid
        Protected WithEvents Grid_Rapor4 As System.Web.UI.WebControls.DataGrid
        Protected WithEvents tarih_baslangic As System.Web.UI.WebControls.TextBox
        Protected WithEvents tarih_bitis As System.Web.UI.WebControls.TextBox
        Protected WithEvents tarih_giris As System.Web.UI.WebControls.Panel
        Protected WithEvents secim_radio As System.Web.UI.WebControls.Panel
        Protected WithEvents rapor1_panel As System.Web.UI.WebControls.Panel
        Protected WithEvents rapor2_panel As System.Web.UI.WebControls.Panel
        Protected WithEvents rapor3_panel As System.Web.UI.WebControls.Panel
        Protected WithEvents rapor4_panel As System.Web.UI.WebControls.Panel
        Protected WithEvents rapor_name As System.Web.UI.WebControls.Label

        'NOTE: The following placeholder declaration is required by the Web Form Designer.
        'Do not delete or move it.
        Private designerPlaceholderDeclaration As System.Object

        Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
            'CODEGEN: This method call is required by the Web Form Designer
            'Do not modify it using the code editor.
            InitializeComponent()
        End Sub

        Public Sub ASPNET_MsgBox(ByVal Message As String)

            System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript"">" & vbCrLf)

            System.Web.HttpContext.Current.Response.Write("alert(""" & Message & """)" & vbCrLf)

            System.Web.HttpContext.Current.Response.Write("</SCRIPT>")

        End Sub


#End Region
        '    Public ilk_internalID As Integer = 0
        Dim button_add As Integer

        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'Put user code to initialize the page here

            ' Dim profnum As String = Page.Request.pa  Form.Item("proc")

            Grid_Rapor1.Visible = False
            Me.rapor1_panel.Visible = False
            Me.rapor2_panel.Visible = False
            Me.rapor3_panel.Visible = False
            Me.rapor4_panel.Visible = False

            If Not Page.IsPostBack Then
                Me.radio1.SelectedIndex = 0
                Me.tarih_baslangic.Text = "27.12.2005"
                Me.tarih_bitis.Text = "27.12.2005"
                Me.tarih_giris.Visible = False
            End If

            Me.PageTitle = "SME Tariff Update Rapor"
            Dim Vproc As String
            Vproc = Me.proc.Value
            Me.proc.Value = ""




            ''If Vproc <> "" And Me.custcode.Text = "" And Me.msisdn.Text = "" Then
            ''    Message = "alert('CustomerCode veya msisdn girmelisiniz ! ')"
            ''    Exit Sub
            ''End If

            ''If Vproc <> "" Then
            ''    Dim sql As String

            ''    If Me.custcode.Text <> "" Then
            ''        'sql = " select * from customer_all where custcode ='" & Me.custcode.Text & "' "
            ''        If CustomerControl(Me.custcode.Text).Rows().Count = 0 Then
            ''            Message = "alert('CustomerCode bulunamadi ! ')"

            ''            Exit Sub
            ''        End If
            ''    Else
            ''        'sql = " select custcode,cslevel,(select custcode from customer_all where customer_id=a.customer_id_high ) from customer_all a where customer_id in "
            ''        'sql = sql + " (select customer_id_high from customer_all where customer_id in "
            ''        'sql = sql + " (select customer_id_high from customer_all where customer_id= "
            ''        'sql = sql + " (select fn_msisdn_to_custid('" & Me.msisdn.Text & "') from dual) "
            ''        'sql = sql + " ) and (cslevel='20' or cslevel='30') "
            ''        'sql = sql + " ) and (cslevel='10' or cslevel='20') "

            ''        Dim temp As DataTable
            ''        temp = msisdnTOcustcode(Me.msisdn.Text)
            ''        If temp.Rows().Count = 0 Then
            ''            Message = "alert('Bu MSISDN e ait sirket bulunamadi ! ')"

            ''            Exit Sub
            ''        Else
            ''            'If temp.Rows(0)(1) = "10" Then
            ''            '    customerCode = temp.Rows(0)(0)
            ''            'Else
            ''            '    customerCode = temp.Rows(0)(2)
            ''            'End If
            ''            customerCode = temp.Rows(0)(0)

            ''        End If

            ''    End If

            ''    'If GetFuPack(customerCode).Rows.Count = 0 Then
            ''    '    Message = "alert('Sirkete ait segment bilgisi bulunamamistir. ! ')"
            ''    '    Exit Sub
            ''    'End If

            ''End If

            Select Case Vproc
                Case "devam"
                    devam()
                Case "excel"
                    excel()
            End Select

        End Sub

        Public Sub devam()


            Me.tarih_giris.Visible = True
            Me.rapor_name.Text = "&nbsp;&nbsp;Rapor:   " & radio1.SelectedValue
            'Me.Grid_Rapor1.Visible = False

            If Me.radio1.SelectedIndex = 0 And Me.secim_radio.Visible = False Then
                Me.Grid_Rapor1.DataSource = Get_User_Count(Me.tarih_baslangic.Text, Me.tarih_bitis.Text)
                Me.Grid_Rapor1.DataBind()
                Me.Grid_Rapor1.Visible = True
                Me.rapor1_panel.Visible = True
                ' Me.button_panel.Visible = False
            End If

            If Me.radio1.SelectedIndex = 1 And Me.secim_radio.Visible = False Then
                Me.Grid_Rapor2.DataSource = Get_Proc_Count(Me.tarih_baslangic.Text, Me.tarih_bitis.Text)
                Me.Grid_Rapor2.DataBind()
                Me.Grid_Rapor2.Visible = True
                Me.rapor2_panel.Visible = True
                ' Me.button_panel.Visible = False
            End If

            If Me.radio1.SelectedIndex = 2 And Me.secim_radio.Visible = False Then
                Me.Grid_Rapor3.DataSource = Get_Error_Proc(Me.tarih_baslangic.Text, Me.tarih_bitis.Text)
                Me.Grid_Rapor3.DataBind()
                Me.Grid_Rapor3.Visible = True
                Me.rapor3_panel.Visible = True
                ' Me.button_panel.Visible = False
            End If

            If Me.radio1.SelectedIndex = 3 And Me.secim_radio.Visible = False Then
                Me.Grid_Rapor4.DataSource = Get_Firm_Tmcode(Me.tarih_baslangic.Text, Me.tarih_bitis.Text)
                Me.Grid_Rapor4.DataBind()
                Me.Grid_Rapor4.Visible = True
                Me.rapor4_panel.Visible = True
                ' Me.button_panel.Visible = False
            End If

            Me.secim_radio.Visible = False

        End Sub


        Public Sub excel()

            Response.Clear()
            Response.Charset = ""
            Response.Cache.SetCacheability(HttpCacheability.NoCache)
            Response.ContentType = "application/vnd.xls"
            Dim stringWrite As System.IO.StringWriter
            stringWrite = New System.IO.StringWriter
            Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)

            If Me.radio1.SelectedIndex = 0 And Me.secim_radio.Visible = False Then
                Response.AddHeader("content-disposition", "attachment;filename=Sme_Rapor1.xls")
                Me.Grid_Rapor1.DataSource = Get_User_Count(Me.tarih_baslangic.Text, Me.tarih_bitis.Text)
                Me.Grid_Rapor1.DataBind()
                Me.Grid_Rapor1.Visible = True
                Me.Grid_Rapor1.RenderControl(htmlWrite)
            End If
            If Me.radio1.SelectedIndex = 1 And Me.secim_radio.Visible = False Then
                Response.AddHeader("content-disposition", "attachment;filename=Sme_Rapor2.xls")
                Me.Grid_Rapor2.DataSource = Get_User_Count(Me.tarih_baslangic.Text, Me.tarih_bitis.Text)
                Me.Grid_Rapor2.DataBind()
                Me.Grid_Rapor2.Visible = True
                Me.Grid_Rapor2.RenderControl(htmlWrite)
                'Response.Clear()
                'Response.AddHeader("content-disposition", "attachment;filename=Sme_Rapor2.xls")
            End If
            If Me.radio1.SelectedIndex = 2 And Me.secim_radio.Visible = False Then
                Response.AddHeader("content-disposition", "attachment;filename=Sme_Rapor3.xls")
                Me.Grid_Rapor3.DataSource = Get_Error_Proc(Me.tarih_baslangic.Text, Me.tarih_bitis.Text)
                Me.Grid_Rapor3.DataBind()
                Me.Grid_Rapor3.Visible = True
                Me.Grid_Rapor3.RenderControl(htmlWrite)
                'Response.Clear()
                'Response.AddHeader("content-disposition", "attachment;filename=Sme_Rapor3.xls")
            End If
            If Me.radio1.SelectedIndex = 3 And Me.secim_radio.Visible = False Then
                Response.AddHeader("content-disposition", "attachment;filename=Sme_Rapor4.xls")
                Me.Grid_Rapor4.DataSource = Get_Firm_Tmcode(Me.tarih_baslangic.Text, Me.tarih_bitis.Text)
                Me.Grid_Rapor4.DataBind()
                Me.Grid_Rapor4.Visible = True
                Me.Grid_Rapor4.RenderControl(htmlWrite)
                'Response.Clear()
                'Response.AddHeader("content-disposition", "attachment;filename=Sme_Rapor3.xls")
            End If

            Response.Write(stringWrite.ToString())
            Response.End()
        End Sub

    End Class



End Namespace